package com.ww.article.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ww.article.mapper.ApArticleMapper;
import com.ww.article.service.ApArticleService;
import com.ww.model.article.dtos.ArticleHomeDto;
import com.ww.model.article.pojos.ApArticle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
@Transactional
public class ApArticleServiceImpl extends ServiceImpl<ApArticleMapper, ApArticle> implements ApArticleService {
    @Autowired(required = false)
    private ApArticleMapper apArticleMapper;
    @Override
    public List<ApArticle> loadApArticle(ArticleHomeDto dto, int type) {
        if(dto.getSize()==null) dto.setSize(10);
        if (dto.getMinBehotTime()==null) dto.setMinBehotTime(new Date());
        if(dto.getMaxBehotTime()==null) dto.setMaxBehotTime(new Date());
        if (dto.getTag()==null) dto.setTag("__all__");
        return apArticleMapper.loadApArticle(dto, type);
    }

}
